const readline = require("readline");
const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
});
let initArr = [];
rl.on("line", (line)=>{
    if(initArr.length === 0) {
        initArr = JSON.parse(line.trim())
        console.log(getResult(initArr))
        // clear
        initArr.length = 0
    }

})

function getResult(initArr) {
    // 长度升序排列, 宽度降序排列
    initArr.sort((a, b) => {
        if(a[0] === b[0]) {
            return a[1] - b[1]
        } else {
            return a[0] - b[0]
        }
    })

    let arr = [initArr[0][1]]
    for (let i = 1; i < initArr.length; i++) {
        let num = initArr[i][1]
        if(num < arr.at(0)) {
            arr.unshift(num)
        } else if (num > arr.at(-1)) {
            arr.push(num)
        } else {
            let index = findIndex(num, arr)
        }
    }
    return arr.length

    // 中间会被替换, 而且是替换大的(return l)
    function findIndex(num, arr) {
        let l = 0
        let r = arr.length - 1
        while( l <= r) {
            let mid = Math.floor((l + r)/2)
            if(arr[mid] >= num) {
                r = mid - 1
            } else{
                l = mid + 1
            }
        }
        return l

    }





}